package com.tuling.netty;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.http.WebSocket;

public class BioClassDemo {
    public static void main(String[] args) {
        try {
            ServerSocket serverSocket = new ServerSocket(9000);
            while (true){
                System.out.println("++++++========等待=====");
                Socket accept = serverSocket.accept();
                System.out.println("++++++=有客户端====");
                handle(accept);
            }


        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static void handle(Socket accept) throws IOException {
        byte[] bytes = new byte[1024];
        int read = accept.getInputStream().read(bytes);
        if(read != -1){
            String result = new String(bytes, 0, read);
            System.out.println("++++++============="+result);
        }

    }


}
